﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Resn.WhuPub.BLL;
using Resn.WhuPub.DML;

namespace Resn.WhuPub.ResetAdmin
{
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {

                public MainWindow()
                {
                        InitializeComponent();
                }

                private void ResetButton_Click(object sender, RoutedEventArgs e)
                {
                        EntityManager<Employee, EmployeeModel> EmployeeEntityManager = new EntityManager<Employee, EmployeeModel>();

                        Employee employee = EmployeeEntityManager.Entitys.FirstOrDefault(i => i.Name == "admin");
                        string password =
                                Encoding.Default.GetString(MD5.Create().ComputeHash(Encoding.Default.GetBytes("admin")));
                        if (employee == null)
                        {
                                employee = Employee.CreateEmployee("admin", password, EmployeeLevel.管理员);
                                employee.Insert();
                        }
                        else
                        {
                                employee.Password = password;
                                employee.Update();
                        }


                }
        }
}
